<template>
    <div>Hello World</div>
    <div>username:{{ username }}</div>
    <div>email:{{ email }}</div>
</template>

<script setup>
import { onMounted, ref } from "vue";
import axios from "axios";
const username = ref("")
const email = ref("")
import { getUsers } from "@/api/user";
import { ElMessage } from "element-plus";


getUsers().then(res => {
    console.log("打印结果")
    if (res === "refresh_token_success") {
      ElMessage.success('令牌刷新成功,请刷新页面');
    } else {
      console.log(res)
      username.value = res.user
    }
    // username.value = res[0].username
    // email.value = res[0].email
})

const login = async () => {
  const data = {
    username: 'jack4',
    password: 'password123',
  }

  try {
    const response = await axios.post('http://localhost:8888/api/v1/login', data, {
      headers: {
        'Content-Type': 'application/json',
      },
    })
    console.log('Response:', response.data)
  } catch (error) {
    console.error('Error:', error.response || error.message)
  }
}

login()


</script>